﻿{% extends "gma/base.html" %}
{% load mytag %}

<!-- CONTENT
  =====================================================================-->

{% block content %}

<div class="page__bd">
    <div class="weui-panel weui-panel_access">
        <div class="weui-panel__hd"> [{{ day }}] 私信列表 </div>
        <div class="weui-panel__bd">
    {% for msg in messages %}
        {% if permissions.review.open %}
            <div class="weui-media-box weui-media-box_appmsg">
                <a href="{% url 'gma:caster_detail' msg.uid %}" class="weui-media-box__hd">
                    <img class="weui-media-box__thumb avatar" src="{{ msg.from_avatar|cdn }}" alt="">
                </a>
{##}
{#                <i class="fa fa-comment"></i>#}
{#                &nbsp; &nbsp;#}
                <a href="{% url 'gma:caster_detail' msg.touid %}" class="weui-media-box__hd">
                    <img class="weui-media-box__thumb avatar" src="{{ msg.to_avatar|cdn }}" alt="">
                </a>

                <div class="weui-media-box__bd">
                    <p class="weui-media-box__desc"> {{ msg.create_time|date:"H:i:s" }} #{{ msg.mid }} </p>
                    <p class="weui-media-box__desc"> {{ msg.pos }}. {{ msg.message }}</p>
                </div>

                <div class="weui-cell__ft">
                {% if msg.review == 0 %}
                    <a href="javascript:review({{ msg.mid }})" class="weui-btn weui-btn_mini weui-btn_warn">审核</a>
                {% else %}
                    <a href="javascript:unreview({{ msg.mid }})" class="weui-btn weui-btn_mini weui-btn_primary">撤审</a>
                {% endif %}
                </div>
            </div>
        {% else %}
            <div class="weui-media-box weui-media-box_appmsg">
                <a href="{% url 'gma:caster_detail' msg.uid %}" class="weui-media-box__hd">
                    <img class="weui-media-box__thumb avatar" src="{{ msg.from_avatar|cdn }}" alt="">
                </a>

                <i class="fa fa-comment"></i>
                &nbsp; &nbsp;
                <a href="{% url 'gma:caster_detail' msg.touid %}" class="weui-media-box__hd">
                    <img class="weui-media-box__thumb avatar" src="{{ msg.to_avatar|cdn }}" alt="">
                </a>

                <div class="weui-media-box__bd">
                    <p class="weui-media-box__desc"> {{ msg.create_time|date:"H:i:s" }} #{{ msg.mid }} </p>
                    <p class="weui-media-box__desc"> {{ msg.pos }}. {{ msg.message }}</p>
                </div>

                <div class="weui-cell__ft">
                </div>
            </div>
        {% endif %}
    {% endfor %}

        </div>
    </div>
</div>

<div class="page__ft">
    <a href="{% url 'gma:home' %}">
        <span class="bottom-logo">
           HiBao
       </span>
    </a>
</div>

{% endblock content %}


<!-- SCRIPT
  =====================================================================-->

{% block extra_js %}

<script>
{% if permissions.review.open %}
function review(mid) {
    show_confirm_dialog('内容审核', '你确定要审核改私信吗?', ()=> {
        let url = "{% url 'gma:api_review_private_message' %}";
        let data = {
            'mid': mid,
        };

        new my_ajax(url, data, '', '', () => {
            show_toast(`聊天记录进入审核状态!`);
            setTimeout(() => {
                window.location.reload();
            }, 1000);
        });
    });
}

function unreview(mid) {
    show_confirm_dialog('取消审核', '你确定要取消对改私信的审核吗?', ()=> {
        let url = "{% url 'gma:api_unreview_private_message' %}";
        let data = {
            'mid': mid,
        };

        new my_ajax(url, data, '', '', () => {
            show_toast(`聊天记录取消审核状态!`);
            setTimeout(() => {
                window.location.reload();
            }, 1000);
        });
    });
}
{% endif %}
</script>

{% endblock extra_js %}